<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>查询弹窗</title>
    <link rel="stylesheet" href="../../../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../../../css/oksub.css">
</head>
<body>
<div class="layui-row" style="margin-right: 10px">
    <form class="layui-form ok-form">
        <div class="layui-form-item">
            <label class="layui-form-label">部门</label>
            <div class="layui-input-block">
                <div name="selDepartment" id="selDepartment"></div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">起始时间</label>
            <div class="layui-input-block">
                <input type="text" placeholder="起始时间" id="startTime" name="startTime" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">终止时间</label>
            <div class="layui-input-block">
                <input type="text" placeholder="终止时间" id="endTime" name="endTime"  autocomplete="off" class="layui-input">
            </div>
        </div>

        <button class="layui-btn" lay-submit="" lay-filter="search"
                style="margin-top:15px;margin-right: 15px;float: right">
            <i class="layui-icon layui-icon-search"></i>
        </button>
    </form>
</div>

<script src="../../../lib/layui/layui.js"></script>
<script src="../../../js/jquery.min.js"></script>
<script src="../../../js/application.js"></script>
<script src="../../../js/selectMore.js"></script>
<script>
    layui.use(["table", 'laydate', 'form'], function () {
        let $ = layui.jquery;
        let table = layui.table;
        let form = layui.form;
        let laydate = layui.laydate;

        //部门多选下拉框
        var selDepartment = xmSelect.render({
            el: '#selDepartment',
            toolbar: {show: true},
            data: []
        });

        //获取派出所信息
        $.ajax({
            url: mainUri + "/dep/getDepartment",
            type: 'post',
            data: {'deepth': 3}
        }).done(function (datas) {
            var list = datas['data'];
            var select = []
            for (var i = 0; i < list.length; i++) {
                select.push({value:list[i]['departmentId'],name:list[i]['departmentName']})
            }
            selDepartment.update({
                data: select,
                autoRow: true,
            });
        }).fail(function () {
            layer.msg("服务器错误");
        });

        //日期
        laydate.render({
            elem: '#startTime',
            trigger: 'click'
        });

        laydate.render({
            elem: '#endTime',
            trigger: 'click'
        });

        let storage = window.localStorage;
        storage.skin = "1";
        storage.anim = "5";

        //监听提交
        form.on('submit(search)', function (data) {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            //将获取到的值穿到父级页面
            var selectArr = selDepartment.getValue('value');
            window.parent.document.selDepartment = selectArr;
            window.parent.document.isChange=1
            window.parent.document.startTime = data.field.startTime;
            window.parent.document.endTime = data.field.endTime;
            parent.layer.close(index);
            return false;
        });
    });
</script>
</body>
</html>